﻿<Window x:Class="MitutoyoRS232DataInputTool.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MitutoyoRS232DataInputTool"
        Title="Mitutoyo RS-232 SPC Data Input Tool (F1 for Help)" 
        Name="myWindow"
        mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="104" d:DesignWidth="1089" SizeToContent="WidthAndHeight" Icon="/MitutoyoRS232DataInputTool;component/Mitutoyo.ico" 
        d:DataContext="{d:DesignInstance Type=local:ViewModel, IsDesignTimeCreatable=True}" Topmost="{Binding Path=AlwaysOnTop}">
    <Window.CommandBindings>
        <CommandBinding Command="Help" CanExecute="HelpCanExecute" Executed="HelpExecuted" />
    </Window.CommandBindings>
    <StackPanel Name="stackPanel1" Orientation="Horizontal">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Label Content="Data:" Height="26" Target="{Binding ElementName=txtData}" Padding="5" Margin="0,3" HorizontalContentAlignment="Right" />
            <TextBox Name="txtData"  Text="{Binding LastDataRead}" Width="84" IsReadOnly="True" VerticalAlignment="Center" Margin="11,5" Grid.Column="1" />
            <Button Content="Get Data" Click="GetData_Click" VerticalAlignment="Center" IsEnabled="{Binding Path=IsConnected}" Margin="0,5" Grid.Column="2" />
            <CheckBox Content="Always On Top" IsChecked="{Binding Path=AlwaysOnTop}" VerticalAlignment="Center" Margin="5,8" Grid.Column="3" />
            <Label Content="Counter:" Height="26" Target="{Binding ElementName=txtData}" Padding="5" Margin="0,3" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" />
            <TextBox Name="txtCounter"  Text="{Binding Path=Counter}" IsReadOnly="True" VerticalAlignment="Center" Margin="11,5,0,5" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" MinWidth="30" />
            <Button Content="Reset" VerticalAlignment="Center" IsEnabled="{Binding Path=IsConnected}" Margin="0,5" Grid.Column="2" Grid.Row="1" Click="Reset_Click" />
        </Grid>
        <Expander ExpandDirection="Right" VerticalAlignment="Center" IsExpanded="True">
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Label Content="COM Port:" Name="label1" Target="{Binding ElementName=cmbComPort}" VerticalAlignment="Center" />
                    <ComboBox Name="cmbComPort" ItemsSource="{Binding Path=AvailablePorts}" SelectedItem="{Binding Path=SelectedPort}" VerticalAlignment="Center" Width="70" />
                    <CheckBox Name="chkEmulateKeyboard" Content="Emulate Keyboard" IsChecked="{Binding Path=EmulateKeyboard}" Margin="5" VerticalAlignment="Center" />
                    <CheckBox Content="Backspace over last data" IsChecked="{Binding Path=BackspacePreviousData}" IsEnabled="{Binding ElementName=chkEmulateKeyboard, Path=IsChecked}" Margin="5" VerticalAlignment="Center" />
                    <Label Content="Prepend:" Target="{Binding ElementName=cmbPrepend}"  IsEnabled="{Binding ElementName=chkEmulateKeyboard, Path=IsChecked}" VerticalAlignment="Center" />
                    <ComboBox Name="cmbPrepend" IsEditable="True" ItemsSource="{Binding Path=PrependOptions}" Text="{Binding Path=Prepend}" IsEnabled="{Binding ElementName=chkEmulateKeyboard, Path=IsChecked}" ToolTip="Keys prepended to data" VerticalAlignment="Center" />
                    <Label Content="Append:" Target="{Binding ElementName=cmbAppend}"  IsEnabled="{Binding ElementName=chkEmulateKeyboard, Path=IsChecked}" VerticalAlignment="Center" />
                    <ComboBox Name="cmbAppend" IsEditable="True" Text="{Binding Path=Append}" ItemsSource="{Binding Path=AppendOptions}" IsEnabled="{Binding ElementName=chkEmulateKeyboard, Path=IsChecked}" ToolTip="Keys appended to data" VerticalAlignment="Center" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox Name="chkEvery" Content="Every" Margin="5" VerticalAlignment="Center" IsChecked="{Binding Path=HasIntermittent}" />
                    <TextBox Name="txtEvery" Margin="0,5" IsEnabled="{Binding ElementName=chkEvery, Path=IsChecked}" MinWidth="20" Text="{Binding Path=IntermittentEvery}" />
                    <Label Content="readings Prepend:" Target="{Binding ElementName=cmbIntermittentPrepend}"  IsEnabled="{Binding ElementName=chkEvery, Path=IsChecked}" VerticalAlignment="Center" Padding="2,5" />
                    <ComboBox Name="cmbIntermittentPrepend" IsEditable="True" ItemsSource="{Binding Path=PrependOptions}" Text="{Binding Path=IntermittentPrepend}" IsEnabled="{Binding ElementName=chkEvery, Path=IsChecked}" ToolTip="Keys prepended to data" VerticalAlignment="Center" />
                    <Label Content=" and Append:" Target="{Binding ElementName=cmbAppend}"  IsEnabled="{Binding ElementName=chkEvery, Path=IsChecked}" VerticalAlignment="Center" />
                    <ComboBox Name="cmbIntermittentAppend" IsEditable="True" Text="{Binding Path=IntermittentAppend}" ItemsSource="{Binding Path=AppendOptions}" IsEnabled="{Binding ElementName=chkEvery, Path=IsChecked}" ToolTip="Keys appended to data" VerticalAlignment="Center" />
                </StackPanel>
            </StackPanel>
        </Expander>
    </StackPanel>
</Window>
